package com.hspedu.newData.每日一题;
/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-06 
 * @Version: 1.0
 */

public class LC1920基于排列构建数组 {

    // 构建一个数组
    public int[] buildArray(int[] nums) {
        int[] ans = new int[nums.length];

        for (int i = 0; i < nums.length; i++) {
            ans[i] = nums[nums[i]];
        }
        return ans;
    }

    // 原地修改
    public int[] buildArray1(int[] nums) {
        for (int i = 0; i < nums.length; i++) {
            nums[i] += 1000*(nums[nums[i]]%1000);
        }
        for (int i = 0; i < nums.length; i++) {
            nums[i] /= 1000;
        }
        return nums;
    }
}
